<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>2.组件</title>
        <!-- 引入Vue -->
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="app">
            <!-- 3.使用组件 -->
        <student></student>
        <student2></student2>
        </div>
    </body>

    <script type="text/javascript">
        //阻止 vue 在启动时生成生产提示。
        Vue.config.productionTip = false

       let student= Vue.extend({
            //    el:"#student",
            template:`
            <div>
            <h1>{{name}}</h1>
            <h1>{{age}}</h1>
            <h1>{{gender}}</h1>
            <button @click="add">又过了一年</button>
            </div>
            `,
            data(){
               return{
                    name:"张三",
                    age:18,
                    gender:'男'
                }
            },
            methods:{
                add(){
                   this.age++
                }
            }
        })

        let student2= Vue.extend({
            //    el:"#student",
            template:`
            <div>
            <h1>{{name}}</h1>
            <h1>人气：{{age}}</h1>
            <h1>{{gender}}</h1>
            <button @click="add">增加人气</button>
            </div>
            `,
            data(){
               return{
                    name:"李荣浩",
                    age:1000,
                    gender:'乌梅子酱'
                }
            },
            methods:{
                add(){
                   this.age+=100
                }
            }
        })

        //2.在vm注册组件

        new Vue({
         el:"#app",
         components:{
            student,
            student2
         }
        })
        
        
    </script>
</html>